package com.yuanli.cosmeticmirror.persenter;

import androidx.lifecycle.LifecycleOwner;

import com.comenjoysoft.baselibrary.listener.CallbackListener;
import com.comenjoysoft.baselibrary.presenter.BasePresenter;
import com.yuanli.cosmeticmirror.bean.FavoriteBean;
import com.yuanli.cosmeticmirror.bean.videoBean;
import com.yuanli.cosmeticmirror.model.biz.IFaoriteBiz;
import com.yuanli.cosmeticmirror.model.impl.FavoriteImpl;
import com.yuanli.cosmeticmirror.model.iview.IFavoriteView;

public class FavoritePersenter extends BasePresenter<IFavoriteView> {
    private final IFaoriteBiz biz;

    public FavoritePersenter(IFavoriteView view, LifecycleOwner owner) {
        attachView(view);
        biz = new FavoriteImpl(owner);
    }

    public void getFavorite() {
        biz.getFavorite(new CallbackListener<FavoriteBean>() {
            @Override
            public void success(FavoriteBean object) {
                mView.onSucess(object);
            }

            @Override
            public void failed(Object object) {
                mView.onError();
            }
        });
    }


    public void delete(String id) {
        biz.cancelCollect(id, new CallbackListener<videoBean>() {
            @Override
            public void success(videoBean object) {
                mView.deteleSucess();
            }

            @Override
            public void failed(Object object) {
                mView.showToast("取消收藏失败");
            }
        });
    }
}
